package org.wk.account;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.wk.account.domain.ConfigEntity;
import org.wk.account.service.ConfigService;

import java.util.List;
import java.util.Map;

/**
 * @author TangShenShen
 * @Description: 服务启动后 初始化config账户参数设置数据
 * @date 2018/6/6 15:33
 */
@Component
public class LoadConfigRunner implements CommandLineRunner {
    @Autowired
    private ConfigService configService;
    @Autowired
    WebApplicationContext webApplicationContext;

    @Override
    @Order(1)
    public void run(String... args) throws Exception {
        List<ConfigEntity> configEntities = configService.selectList();
        webApplicationContext.getServletContext().setAttribute("config",configEntities);
    }
}
